package com.yz.order.controller;

import com.yz.api.facade.order.OrderFacade;
import com.yz.model.dto.order.OrderRequest;
import com.yz.model.dto.order.PayOrderRequest;
import com.yz.model.vo.order.OrderVo;
import com.yz.common.resp.BaseResponse;
import com.yz.common.utils.ResultUtils;
import com.yz.order.service.OrderService;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * <p>
 * User:Mr.Du
 * Date:2024/4/9
 * Time:10:16
 */
@RestController
public class OrderController implements OrderFacade {

    @Resource
    private OrderService orderService;

    @Override
    public BaseResponse<OrderVo> returnOrderInfo(Long uid, OrderRequest orderRequest) {
        if(orderRequest == null || uid == null){
            throw new RuntimeException("参数不能为空");
        }
        Long amount = orderRequest.getAmount();
        String codes = orderRequest.getCodes();
        if(StringUtils.isBlank(amount.toString())){
            throw new RuntimeException("参数不能为空");
        }
        OrderVo orderVo = orderService.returnOrderInfo(uid, amount, codes);
        return ResultUtils.success(orderVo);
    }

    @Override
    public BaseResponse<String> orderReCharge(Long uid, PayOrderRequest payOrderRequest) {
        if(payOrderRequest == null || uid == null){
            throw new RuntimeException("参数不能为空");
        }
        String res = orderService.orderReCharge(uid, payOrderRequest);
        return ResultUtils.success("",res);
    }
}
